<?php

namespace app\common\model;

use think\Model;

class Fans extends Model
{
    //
    protected $autoWriteTimestamp=true;

    public function fanUser(){
        return $this->hasOne('Users','uid','fan_id');
    }

    //粉丝的关注信息
    public function fanFollowers(){
        return $this->hasMany('Follows','user_id','fan_id')->where('status',1);
    }

    //粉丝的粉丝信息
    public function fanFans(){
        return $this->hasMany('Fans','user_id','fan_id')->where('status',1);
    }

    //粉丝的文章信息
    public function fanPosts(){
        return $this->hasMany('BgPosts','uid','fan_id')->where('status',1);
    }

    //当前用户是否关注了此粉丝
    public function hasFollow(){
        return $this->hasMany('Fans','user_id','fan_id')->where('fan_id',session('uid'))->where('status',1);
    }
}
